//
//  printViewController.m
//  BeautyPicture
//
//  Created by 沈振邦 on 15/7/27.
//  Copyright (c) 2015年 szb. All rights reserved.
//

#import "printViewController.h"
#import "printDetailVC.h"
#import "shaidanListVC.h"
#import "shareCenterVC.h"
#import "BPhttpTool.h"
#import "MJRefresh.h"

@interface printViewController ()

@property (nonatomic,assign)int refreshIndex;

@end

@implementation printViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _refreshIndex = 0;
    //[self downloadXiuData];
    
}

- (void)setUpRefreshView
{
//    self.baseWebView.scrollView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
//        _refreshIndex ++;
//        [self.context[@"loadingPage"] callWithArguments:@[[NSString stringWithFormat:@"%d",_refreshIndex]]];
//    }];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self.context[@"loadingPage"] callWithArguments:@[[NSString stringWithFormat:@"%d",_refreshIndex]]];
    self.baseWebView.scrollView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        _refreshIndex ++;
        [self.context[@"loadingPage"] callWithArguments:@[[NSString stringWithFormat:@"%d",_refreshIndex]]];
    }];
}

- (void)endRefresh
{
    [self.baseWebView.scrollView.mj_footer endRefreshing];
}

- (void)pushToxiuDetail:(NSString *)webName :(NSDictionary *)jsObj
{
    //NSLog(@"%@",jsObj);
    printDetailVC *detail = [[printDetailVC alloc] init];
    detail.title = @"作品详情";
    detail.webName = webName;
    detail.jsObjc = jsObj;
    detail.block = ^(NSString *type , NSString *showID){
        NSDictionary *dic = @{
                              @"type":type,
                              @"showid":showID,
                              };
        [self.context[@"callback"] callWithArguments:@[dic]];
    };
    [self.navigationController pushViewController:detail animated:YES];
}

- (void)pushToVC:(NSString *)vcName
{
    if ([vcName isEqualToString:@"showOrder"]) {
        shaidanListVC *order = [[shaidanListVC alloc] init];
        order.title = @"我的晒单";
        order.block = ^(){
            [self.baseWebView reload];
        };
        [self.navigationController pushViewController:order animated:YES];
        
    }else if ([vcName isEqualToString:@"shareOther"]) {
        shareCenterVC *share = [[shareCenterVC alloc] init];
        share.title = @"我的分享";
        [self.navigationController pushViewController:share animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
